
package protocol.transactions;

import protocol.XoneProtocol;
import protocol.XoneServiceCode;

import com.netease.http.THttpRequest;

public class SubscribeTransaction extends XoneBaseTransaction {

    private int mSubjectId;
    private int mSourceId;

    public SubscribeTransaction(int subjectId, int sourceId) {
        super(TRANSACTION_TYPE_SUBSCRIBE);
        mSubjectId = subjectId;
        mSourceId = sourceId;
    }

    @Override
    public void onTransact() {
        THttpRequest request = XoneProtocol.getInstance().createSubscribelRequest(mSubjectId,
                mSourceId);
        sendRequest(request);
    }

    @Override
    protected void onXoneTransactionSuccess(int code, Object obj) {
        int subjectIdAndSourceId[] = new int[2];
        subjectIdAndSourceId[0] = mSubjectId;
        subjectIdAndSourceId[1] = mSourceId;
        notifyMessage(XoneServiceCode.TRANSACTION_SUCCESS, subjectIdAndSourceId);
    }

}
